{% extends "base.html" %}
{% load i18n %}
{% load static %}
{% load humanize %}
{% load display_tags %}
{% load authorization_tags %}
{% block add_styles %}
    {{ block.super }}
  .chart {height: 160px}
{% endblock %}
{% block content %}
    {{ block.super }}
<div class="row">
  <div class="col-md-8">
    <div class="panel panel-default">
      <div class="panel-heading tight">
        <div class="clearfix">
          <h3 class="pull-left">{% trans "Description" %}</h3>
          <div class="dropdown pull-right">
            <div class="btn-group">
              <button class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-expanded="true" aria-label="Options">
                <span class="fa-solid fa-bars"></span>
                <span class="caret"></span>
              </button>
              <ul class="dropdown-menu dropdown-menu-right" role="menu" aria-labelledby="dropdownMenu1">
                {% if prod|has_object_permission:"Product_Edit" %}
                  <li role="presentation">
                    <a class="" href="{% url 'edit_product' prod.id %}">
                                          <i class="fa-solid fa-pen-to-square"></i> {% trans "Edit" %}
                                      </a>
                  </li>
                  <li role="separator" class="divider"></li>
                  <li role="presentation">
                    <a class="" href="{% url 'add_meta_data' prod.id %}">
                        <i class="fa-solid fa-plus"></i>{% trans "Add Custom Fields" %}
                    </a>
                  </li>
                  <li role="presentation">
                    <a title="Edit Custom Fields"
                      href="{% url 'edit_meta_data' prod.id %}">
                        <i class="fa-solid fa-pen-to-square"></i>{% trans "Edit Custom Fields" %}
                    </a>
                  </li>
                {% endif %}
                <li role="separator" class="divider"></li>
                {% if prod|has_object_permission:"Product_API_Scan_Configuration_Add" %}
                  <li role="presentation">
                    <a class="" href="{% url 'add_api_scan_configuration' prod.id %}">
                      <i class="fa-solid fa-plus"></i>{% trans "Add API Scan Configuration" %}
                    </a>
                  </li>
                {% endif %}
                <li role="presentation">
                    <a title="View API Scan Configurations"
                        href="{% url 'view_api_scan_configurations' prod.id %}">
                        <i class="fa-solid fa-rectangle-list"></i>{% trans "View API Scan Configurations" %}
                    </a>
                </li>
                {% if system_settings.enable_product_tracking_files %}
                  <li role="separator" class="divider"></li>
                  {% if prod|has_object_permission:"Product_Tracking_Files_Add" %}
                  <li role="presentation">
                    <a class="" href="{% url 'new_object' prod.id %}">
                        <i class="fa-solid fa-plus"></i> {% trans "Add Tracked Files" %}
                    </a>
                  </li>
                  {% endif %}
                  {% if prod|has_object_permission:"Product_Tracking_Files_View" %}
                  <li role="presentation">
                    <a href="{% url 'view_objects' prod.id %}">
                        <i class="fa-solid fa-rectangle-list"></i> {% trans "View Tracked Files" %}
                    </a>
                  </li>
                  {% endif %}
                {% endif %}
                <li role="separator" class="divider"></li>
                <li role="presentation">
                  <a href="{% url 'product_report' prod.id %}?title=&active=1&verified=1&false_p=2&duplicate=2">
                      <i class="fa-solid fa-file-lines"></i> {{ labels.ASSET_REPORT_LABEL }}
                  </a>
                </li>
                {% if prod|has_object_permission:"Benchmark_Edit" %}
                  {% if system_settings.enable_benchmark and benchmark_type %}
                    <li role="separator" class="divider"></li>
                    {% for bt in benchmark_type %}
                    <li role="presentation">
                      <a title="{{ bt.name }}" href="{% url 'view_product_benchmark' prod.id bt.id %}">
                                        <span class="fa-solid fa-list-ul"></span> {{ bt.name }} {{ bt.version }}
                                    </a>
                    </li>
                    {% endfor %}
                  {% endif %}
                {% endif %}
                {% if prod|has_object_permission:"Product_Edit" %}
                  <li role="separator" class="divider"></li>
                  <li role="presentation">
                    <a href="{% url 'action_history' prod|content_type prod.id %}">
                        <i class="fa-solid fa-clock-rotate-left"></i>{% trans "View History" %}
                    </a>
                  </li>
                {% endif %}
                {% if prod|has_object_permission:"Product_Delete" %}
                  <li role="separator" class="divider"></li>
                  <li role="presentation">
                    <a class="text-danger" href="{% url 'delete_product' prod.id %}">
                        <i class="fa-solid fa-trash"></i>{% trans "Delete" %}
                    </a>
                  </li>
                {% endif %}
              </ul>
            </div>
          </div>
        </div>
      </div>
      <div class="panel-body">
        {{ prod.description|markdown_render }}
      </div>
    </div>
<!-- metrics -->

<div class="row">
<div class="col-md-12">
  <div class="panel panel-default">
    <div class="panel-heading">
      <h3 class="panel-title"><span class="fa-solid fa-chart-pie mr-2" aria-hidden="true"></span>{% trans "Metrics" %}</h3>
    </div>
    <table class="table table-condensed">
      <tbody>
        <tr>
          <td class="col-sm-2 bg-vuln-critical vuln-count text-center">
              <a aria-label="{{ critical }} critical findings" href="{% url 'product_open_findings' prod.id %}?severity=Critical" style="color:#FFFFFF;text-decoration:none">{{ critical }}<span class="hidden-xs"><br>
              <small>{% trans "CRITICAL" %}</small></span></a>
          </td>
          <td class="col-sm-2 bg-vuln-high vuln-count text-center">
              <a aria-label="{{ high }} high severity findings" href="{% url 'product_open_findings' prod.id %}?severity=High" style="color:#FFFFFF;text-decoration:none">{{ high }}<span class="hidden-xs"><br>
              <small>{% trans "HIGH" %}</small></span></a>
          </td>
          <td class="col-sm-2 bg-vuln-medium vuln-count text-center">
              <a aria-label="{{ medium }} medium severity findings" href="{% url 'product_open_findings' prod.id %}?severity=Medium" style="color:#FFFFFF;text-decoration:none">{{ medium }}<span class="hidden-xs"><br>
              <small>{% trans "MEDIUM" %}</small></span></a>
          </td>
          <td class="col-sm-2 bg-vuln-low vuln-count text-center">
              <a aria-label="{{ low }} low severity findings" href="{% url 'product_open_findings' prod.id %}?severity=Low" style="color:#FFFFFF;text-decoration:none">{{ low }}<span class="hidden-xs"><br>
              <small>{% trans "LOW" %}</small></span></a>
          </td>
          <td class="col-sm-2 bg-vuln-info vuln-count text-center">
              <a aria-label="{{ informational }} informational severity findings" href="{% url 'product_open_findings' prod.id %}?severity=Info" style="color:#FFFFFF;text-decoration:none">{{ info }}<span class="hidden-xs"><br>
              <small>{% trans "INFORMATIONAL" %}</small></span></a>
          </td>
          <td class="col-sm-2 bg-muted vuln-count text-center">
              <a href="{% url 'product_open_findings' prod.id %}" style="color:#FFFFFF;text-decoration:none">{{ total }}<span class="hidden-xs"><br>
              <small>{% trans "TOTAL" %}</small></span></a>
          </td>
        </tr>
      </tbody>
    </table>
  </div>
</div>
</div>
<!-- end metrics -->
<div class="row">
  <div class="col-md-6">
    <div class="panel panel-default">
      <div class="panel-heading">
        <h3 class="panel-title"><span class="fa-solid fa-bolt" aria-hidden="true"></span>{% trans "Technologies" %} {% if app_analysis %}({{ app_analysis.count }}){% endif %}
            {% if prod|has_object_permission:"Technology_Add" %}
            <a title="{% trans "Add new Technology" %}" class="pull-right btn btn-sm btn-primary" href="/product/{{ prod.id }}/new_technology" id="addTechnology"><span class="fa-solid fa-plus"></span> </a>
            {% endif %}
        </h3>
      </div>
      {% if app_analysis %}
      <table class="tablesorter-bootstrap table table-condensed table-striped">
         <tbody>
            {% for app in app_analysis %}
            <tr>
                <td>
                    <ul>
                    <li class="dropdown" style="list-style:none;position:absolute">
                        <a href="#" class="dropdown-toggle pull-left" data-toggle="dropdown" aria-expanded="true" label="Actions" name="dropdownManageTechnologies"><b class="fa-solid fa-ellipsis-vertical"></b>&nbsp;</a>
                        <ul class="dropdown-menu">
                            {% if prod|has_object_permission:"Technology_Edit" %}
                            <li>
                                <a name="editTechnology" href="{% url 'edit_technology' app.id %}">
                                <i class="fa-solid fa-pen-to-square"></i>{% trans "Edit" %}</a>
                            </li>
                            {% endif %}
                            {% if prod|has_object_permission:"Technology_Delete" %}
                            <li>
                                <a name="deleteTechnology" href="{% url 'delete_technology' app.id %}">
                                <i class="fa-solid fa-trash"></i>{% trans "Delete" %}</a>
                            </li>
                            {% endif %}
                        </ul>
                    </li>
                    </ul>
                </td>
                <td name="technology_name">{{ app.name }}</td>
                <td name="technology_version"><span class="badge">{{ app.version|version_num }}</span></td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
    {% else %}
        <ul class="list-group">
            <li class="list-group-item"><small class="text-muted"><em>{% trans "There are no technologies." %}</em></small></li>
        </ul>
    {% endif %}
</div>
  </div>
  <div class="col-md-6">
    <div class="panel panel-default">
      <div class="panel-heading">
        <h3 class="panel-title"><span class="fa-solid fa-gavel" aria-hidden="true"></span>{% trans "Regulations" %} {% if prod.regulations.count > 0%}({{ prod.regulations.count }}){%endif%}</h3>
      </div>
      <ul class="list-group">
      {% for regulation in prod.regulations.all %}
        <li class="list-group-item"><span class="badge">{{ regulation.get_category_display }}</span><span data-toggle="tooltip" data-placement="bottom" title="{{ product.regulation.name }}">{{ regulation.acronym }}</span> <small class="text-muted">{{ regulation.jurisdiction }}</small></li>
      {% empty %}
        <li class="list-group-item"><small class="text-muted"><em>{% trans "There are no regulations." %}</em></small></li>
      {% endfor %}
      </ul>

    </div>
  </div>
</div>

<!-- Benchmark Tab -->
{% if system_settings.enable_benchmark %}
<div class="row">
  <div class="col-md-12">
    <div class="panel panel-default">
      <div class="panel-heading">
        <h3 class="panel-title"><span class ="fa-solid fa-scale-balanced" aria-hidden="true"></span>{% trans "Benchmark Progress" %}</h3>
      </div>
        <ul class="list-group">
          {% for benchmark in benchmarks_percents %}
          <li class="list-group-item">
          <a href="{% url 'view_product_benchmark' prod.id benchmark.id %}">
            <div class="row">
                <div class="col-md-6">
                    <span class="float-md-left"><strong>{{benchmark.name}}</strong> ({{ benchmark.level }})</span>
                </div>
                <div class="col-md-6 text-right">
                    <span class="float-md-right">{{ benchmark.pass|percentage:benchmark.total }} {% trans "complete" %}</span>
                </div>
            </div>
            <div class="progress">
                <div class="progress-bar progress-bar-success" data-toggle="tooltip" data-placement="bottom"
                     title="{% trans "Successful" %} - {{ benchmark.success.percent }}%"
                     style="width: {{ benchmark.success.percent|floatformat:"2u" }}%">
                    <span class="sr-only">{{ benchmark.success.percent|floatformat }}%</span>
                </div>
                <div class="progress-bar progress-bar-warning" data-toggle="tooltip" data-placement="bottom"
                     title="{% trans "Pending" %} - {{ benchmark.waiting.percent}}%"
                     style="width: {{ benchmark.waiting.percent|floatformat:"2u" }}%">
                    <span class="sr-only">{{ benchmark.waiting.percent|floatformat }}%</span>
                </div>
                <div class="progress-bar progress-bar-danger" data-toggle="tooltip" data-placement="bottom"
                     title="{% trans "Identified" %} - {{ benchmark.fail.percent }}%"
                     style="width: {{ benchmark.fail.percent|floatformat:"2u" }}%">
                    <span class="sr-only">{{ benchmark.fail.percent|floatformat }}%</span>
                </div>
            </div>
          </a>
          </li>
          {% empty %}
            <li class="list-group-item"><small class = "text-muted"><em>{% trans "There are no benchmarks" %}</em></small></li>
          {% endfor %}
        </ul>
    </div>
  </div>
</div>
{% endif %}

    <div class="panel panel-default">
        <div class="panel-heading">
            <div class="clearfix">
                <h4 class="pull-left">{% trans "Members" %}</h4>
                &nbsp;
                <a href="https://docs.defectdojo.com/en/customize_dojo/user_management/about_perms_and_roles/#productproduct-type-membership--roles" target="_blank">
                    <i class="fa-solid fa-circle-question"></i></a>
                {% if prod|has_object_permission:"Product_Manage_Members" %}
                <div class="dropdown pull-right">
                    <button class="btn btn-primary dropdown-toggle" label="Actions" type="button" id="dropdownMenuAddProductMember"
                            data-toggle="dropdown" aria-expanded="true" aria-label="Add Product Member">
                        <span class="fa-solid fa-bars"></span>
                        <span class="caret"></span>
                    </button>
                    <ul class="dropdown-menu dropdown-menu-right" role="menu" aria-labelledby="dropdownMenu1">
                        <li role="presentation">
                            <a id="addProductMember" href="{% url 'add_product_member' prod.id %}">
                                <i class="fa-solid fa-plus"></i>{% trans "Add Users" %}
                            </a>
                        </li>
                    </ul>
                </div>
                {% endif %}
            </div>
        </div>
        {% if product_members or product_type_members or global_product_members %}
            <div class="table-responsive">
                <table class="tablesorter-bootstrap table table-condensed table-striped">
                    <thead>
                    <tr>
                        <th label="Actions"></th>
                        <th>{% trans "User" %}</th>
                        <th>{% trans "Source" %}</th>
                        <th>{% trans "Role" %}</th>
                    </tr>
                    </thead>
                    <tbody>
                    {% for member in product_members %}
                        <tr>
                            <td>
                                <ul>
                                <li class="dropdown" style="list-style:none;position:absolute">
                                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="true" label="Actions" name="dropdownManageProductMember">&nbsp;<b class="fa-solid fa-ellipsis-vertical"></b>&nbsp;</a>
                                    <ul class="dropdown-menu">
                                        {% if prod|has_object_permission:"Product_Manage_Members" %}
                                        <li>
                                            <a name="editProductMember" href="{% url 'edit_product_member' member.id %}">
                                            <i class="fa-solid fa-pen-to-square"></i>{% trans "Edit" %}</a>
                                        </li>
                                        {% endif %}
                                        {% if member|has_object_permission:"Product_Member_Delete" %}
                                        <li>
                                            <a name="deleteProductMember" href="{% url 'delete_product_member' member.id %}">
                                            <i class="fa-solid fa-trash"></i>{% trans "Delete" %}</a>
                                        </li>
                                        {% endif %}
                                    </ul>
                                </li>
                                </ul>
                            </td>
                            <td name="member_user">{{ member.user.get_full_name }}</td>
                            <td>{{ labels.ASSET_USERS_MEMBER_LABEL }}</td>
                            <td name="member_role">{{ member.role }}</td>
                        </tr>
                    {% endfor %}
                    {% for member in product_type_members %}
                        <tr>
                            <td>
                            </td>
                            <td>{{ member.user.get_full_name }}</td>
                            <td>
                                <a class="" href="{% url 'view_product_type' member.product_type.id %}">
                                    {{ labels.ORG_LABEL }}: {{ member.product_type }}
                                </a>
                            </td>
                            <td>{{ member.role }}</td>
                        </tr>
                    {% endfor %}
                    {% for member in global_product_members %}
                        <tr>
                            <td>
                            </td>
                            <td>{{ member.user.get_full_name }}</td>
                            <td>Global role</td>
                            <td>{{ member.role }}</td>
                        </tr>
                    {% endfor %}
                    </tbody>
                </table>
            </div>
        {% else %}
            <div class="panel-body">
                <small class="text-muted"><em>{% trans "No members found." %}</em></small>
            </div>
        {% endif %}
    </div>

      <div class="panel panel-default">
          <div class="panel-heading">
              <div class="clearfix">
                  <h4 class="pull-left">{% trans "Groups" %}</h4>
                  &nbsp;
                  <a href="https://docs.defectdojo.com/en/customize_dojo/user_management/about_perms_and_roles/#group-memberships" target="_blank">
                      <i class="fa-solid fa-circle-question"></i></a>
                  {% if prod|has_object_permission:"Product_Group_Add" %}
                  <div class="dropdown pull-right">
                      <button class="btn btn-primary dropdown-toggle" label="Actions" type="button" id="dropdownMenuAddProductGroup"
                              data-toggle="dropdown" aria-expanded="true" aria-label="Add Product Group">
                          <span class="fa-solid fa-bars"></span>
                          <span class="caret"></span>
                      </button>
                      <ul class="dropdown-menu dropdown-menu-right" role="menu" aria-labelledby="dropdownMenu1">
                          <li role="presentation">
                              <a id="addProductGroup" href="{% url 'add_product_group' prod.id %}">
                                  <i class="fa-solid fa-plus"></i>{% trans "Add Groups" %}
                              </a>
                          </li>
                      </ul>
                  </div>
                  {% endif %}
              </div>
          </div>
          {% if product_groups or product_type_groups or global_product_groups %}
          <div class="table-responsive">
              <table class="tablesorter-bootstrap table table-condensed table-striped">
                  <thead>
                  <tr>
                      <th label="Actions"></th>
                      <th>{% trans "Group" %}</th>
                      <th>{% trans "Source" %}</th>
                      <th>{% trans "Role" %}</th>
                  </tr>
                  </thead>
                  <tbody>
                  {% for group in product_groups %}
                  <tr>
                      <td>
                          <ul>
                              <li class="dropdown" style="list-style:none;position:absolute">
                                  <a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="true" label="Actions" name="dropdownManageProductGroup">&nbsp;<b class="fa-solid fa-ellipsis-vertical"></b>&nbsp;</a>
                                  <ul class="dropdown-menu">
                                      {% if prod|has_object_permission:"Product_Group_Edit" %}
                                      <li>
                                          <a name="editProductGroup" href="{% url 'edit_product_group' group.id %}">
                                              <i class="fa-solid fa-pen-to-square"></i>{% trans "Edit" %}</a>
                                      </li>
                                      {% endif %}
                                      {% if group|has_object_permission:"Product_Group_Delete" %}
                                      <li>
                                          <a name="deleteProductGroup" href="{% url 'delete_product_group' group.id %}">
                                              <i class="fa-solid fa-trash"></i>{% trans "Delete" %}</a>
                                      </li>
                                      {% endif %}
                                  </ul>
                              </li>
                          </ul>
                      </td>
                      <td name="group_name">{{ group.group.name }}</td>
                      <td name="group_source">{{ labels.ASSET_GROUPS_MEMBER_LABEL }}</td>
                      <td name="group_role">{{ group.role }}</td>
                  </tr>
                  {% endfor %}
                  {% for type_group in product_type_groups %}
                  <tr>
                      <td></td>
                      <td>{{ type_group.group.name }}</td>
                      <td>
                          <a class="" href="{% url 'view_product_type' type_group.product_type.id %}">
                              {{ type_group.product_type }}
                          </a>
                      </td>
                      <td>{{ type_group.role }}</td>
                  </tr>
                  {% endfor %}
                  {% for type_group in global_product_groups %}
                  <tr>
                      <td></td>
                      <td>{{ type_group.group.name }}</td>
                      <td>Global role</td>
                      <td>{{ type_group.role }}</td>
                  </tr>
                  {% endfor %}
                  </tbody>
              </table>
          </div>
          {% else %}
          <div class="panel-body">
              <small class="text-muted"><em>{% trans "No groups found." %}</em></small>
          </div>
          {% endif %}
      </div>

</div>
<!-- Meta Data -->
<div class="col-md-4">
  <div class="panel panel-default panel-default-secondary">
    <div class="panel-heading">
      <h3 class="panel-title"><span class="fa-solid fa-circle-info fa-fw" aria-hidden="true"></span>{% trans "Metadata" %}</h3>
    </div>
    <div class="table-responsive">
      <table class="table table-striped" id="set-width">
        <tbody>
          <tr>
            <td style="width: 160px;"><strong>{% trans "Business Criticality" %}</strong></td>
            <td>{{ prod.get_business_criticality_display|notspecified }}</td>
          </tr>
          <tr>
            <td><strong>{{ labels.ORG_LABEL }}</strong></td>
            <td><a title="{{ labels.ORG_LABEL }}" href="{% url 'view_product_type' prod.prod_type.id %}">{{ prod.prod_type }}</a></td>
          </tr>
          <tr>
            <td><strong>{% trans "Platform" %}</strong></td>
            <td>{{ prod.get_platform_display|notspecified }}</td>
          </tr>
          <tr>
            <td><strong>{% trans "Lifecycle" %}</strong></td>
            <td>{{ prod.get_lifecycle_display|notspecified }}</td>
          </tr>
          <tr>
            <td><strong>{% trans "Origin" %}</strong></td>
            <td>{{ prod.get_origin_display|notspecified }}</td>
          </tr>
          <tr>
            <td><strong>{% trans "User Records" %}</strong></td>
            <td>
              {%  if prod.user_records > 0 %}
              {{ prod.user_records|intcomma }}
              {% else %}
              {{ prod.user_records|notspecified }}
              {% endif %}
            </td>
          </tr>
          <tr>
            <td><strong>{% trans "Revenue" %}</strong></td>
            <td>
              {%  if prod.revenue > 0 %}
                {% if prod.revenue < 1000000 %}{{ prod.revenue|intcomma }}{% else %}{{ prod.revenue|intword }}{% endif %}
              {% else %}
                {{ prod.revenue|notspecified }}
              {% endif %}
            </td>
          </tr>
          {% with jira_project=prod|jira_project %}
            {% if jira_project %}
            <tr>
              <td><strong>{% trans "JIRA" %}</strong></td>
              <td><a href="{{ prod | jira_project_url }}" target="_blank"><i class="fa-solid fa-arrow-up-right-from-square"></i> {{ prod | jira_key }}</a></td>
            </tr>
            {% endif %}
          {% endwith %}
        </tbody>
      </table>
    </div>
  </div>

<!-- End metadata -->
<!-- SLA -->
    {% if system_settings.enable_finding_sla %}
    <div class="panel panel-default panel-default-secondary">
    <div class="panel-heading">
      <h3 class="panel-title"><span class="fa-solid fa-calendar-check fa-fw" aria-hidden="true"></span>&nbsp;Service Level Agreement</h3>
    </div><div class="panel-body">
        <p>{{ sla.name }}</p>
        <p>{{ sla.description }}</p>
      </div>
    <div class="table-responsive">
      <table class="table table-striped" >
        <tbody>
          <tr>
            <td style="width: 160px;"><strong>Critical</strong></td>
            <td>
              {% if sla.enforce_critical %}
                {{ sla.critical }} days to remediate
              {% else %}
                <em class="text-muted">Not Enforced</em>
              {% endif %}
            </td>
          </tr>
          <tr>
            <td style="width: 160px;"><strong>High</strong></td>
            <td>
              {% if sla.enforce_high %}
                {{ sla.high }} days to remediate
              {% else %}
                <em class="text-muted">Not Enforced</em>
              {% endif %}
            </td>
          </tr>
          <tr>
            <td style="width: 160px;"><strong>Medium</strong></td>
            <td>
              {% if sla.enforce_medium %}
                {{ sla.medium }} days to remediate
              {% else %}
                <em class="text-muted">Not Enforced</em>
              {% endif %}
            </td>
          </tr>
          <tr>
            <td style="width: 160px;"><strong>Low</strong></td>
            <td>
              {% if sla.enforce_low %}
                {{ sla.low }} days to remediate
              {% else %}
                <em class="text-muted">Not Enforced</em>
              {% endif %}
            </td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
{% endif %}
<!-- End SLA -->
<!-- Lang -->
{% if languages %}
  <div class="panel panel-default panel-default-secondary">
    <div class="panel-heading">
      <h3 class="panel-title"><span class="fa-solid fa-language" aria-hidden="true"></span>{% trans "Languages" %} ({{ languages.count }})</h3>
    </div>
    <div class="panel-body" style="text-align: center;">
      <div style="display: inline-block; padding: 0px 15px 0px 15px; vertical-align: top;">
        <div class="chart" id="donut-lang"></div>
        <div style="padding: 10px 0px 10px 0px;">
            {%  if langSummary.files__sum > 0 %}
            <strong>{{ langSummary.files__sum|intcomma }}</strong> {% trans "files" %} {%  if langSummary.code__sum %} {% trans "and" %} {%endif%}
            {% endif %}
            {%  if langSummary.code__sum %}
            <strong>{{ langSummary.code__sum|intcomma }}</strong> {% trans "lines of code" %}
            {% endif %}
        </div>
      </div>
      <div style="display: inline-block; padding: 0px 15px 0px 15px; white-space: nowrap; overflow-x: scroll; text-align: left;">
        <div id="donut-lang-container"></div>
      </div>
    </div>
  </div>
{% endif %}
<!-- end lang  -->
<!-- Custom fields -->
{% if product_metadata %}
  <div class="panel panel-default panel-default-secondary">
    <div class="panel-heading">
      <h3 class="panel-title"><span class="fa-solid fa-wand-magic-sparkles fa-fw" aria-hidden="true"></span>{% trans "Custom Fields" %}</h3>
    </div>
    <div class="table-responsive">
      <table class="table table-striped">
        <tbody>
          {% for key, value in product_metadata.items %}
          <tr>
            <td style="width: 160px;"><strong>{{ key }}</strong></td>
            <td>{{ value }}</td>
          </tr>
          {% endfor %}
        </tbody>
      </table>
    </div>
  </div>
{% endif %}
<!-- end custom fields -->
<!-- Contacts -->
  <div class="panel panel-default panel-default-secondary">
    <div class="panel-heading">
      <h3 class="panel-title"><span class="fa-solid fa-users fa-fw" aria-hidden="true"></span>{% trans "Contacts" %}</h3>
    </div>
    <div class="table-responsive">
      <table class="table table-striped">
        <tbody>
          <tr>
            <td style="width: 160px;"><strong>{% trans "Team Manager" %}</strong></td>
            <td>{% if prod.team_manager != "0" %}{{ prod.team_manager | default:"Unknown" }}{% endif %}</td>
          </tr>
          <tr>
            <td><strong>{{ labels.ASSET_MANAGER_LABEL }}</strong></td>
            <td>{% if prod.product_manager != "0" %}{{ prod.product_manager | default:"Unknown" }}{% endif %}</td>
          </tr>
          <tr>
            <td><strong>{% trans "Technical Contact" %}</strong></td>
            <td>{% if prod.technical_contact != "0" %}{{ prod.technical_contact | default:"Unknown" }}{% endif %}</td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
<!-- end contacts -->
<!-- Notifications -->
<div class="panel panel-default panel-default-secondary" id="edit_notifications">
  <div class="panel-heading">
    {% url 'notifications' as notifications_url %}
    <h3 class="panel-title"><span class="fa-solid fa-users fa-fw" aria-hidden="true"></span>{% trans "Notifications" %}
      <i class="fa-solid fa-circle-question has-popover" data-trigger="hover" data-content="{{ labels.ASSET_NOTIFICATIONS_HELP }}" %}" data-placement="right" data-container="body"></i>
    </h3>
  </div>
  <form id="edit_notifications_form" class="form-horizontal" method="post" action="{% url 'edit_notifications' prod.id %}">{% csrf_token %}
    <div class="table-responsive">
      <table class="table table-striped">
        <tbody>
          <tr>
              <td id="saving_notifications">&nbsp;</td>
              {% if "slack" in enabled_notifications %}
              <td class="centered">{% trans "Slack" %}</td>
              {% endif %}
              {% if "mail" in enabled_notifications %}
              <td class="centered">{% trans "Mail" %}</td>
              {% endif %}
              <td class="centered">{% trans "Alert" %}</td>
          </tr>
          {% for field in personal_notifications_form.visible_fields %}
          <tr>
            <td><strong>{{ field.label }}&nbsp;</strong>
              {% if field.help_text %}
              <i class="fa-solid fa-circle-question has-popover" data-trigger="hover" data-content="{{ field.help_text }}" data-placement="right" data-container="body"></i>
              {% endif %}
            </td>
            {% for pk,c in field.field.widget.choices %}
            {% if c != "msteams" and c != "webhooks" and c in enabled_notifications %}
            <td class="centered"><input id="{{ field.name }}_{{ c }}" type="checkbox" name="{{ field.name }}" {% if c in field.value %}checked{% endif %} value="{{ c }}"/></td>
            {% endif %}
            {% endfor %}
         </tr>
          {% endfor %}
        </tbody>
      </table>
  </div>
  </form>
</div>
<!-- end Notifications -->

</div>
</div>
{% endblock %}
{% block postscript %}
    {{ block.super }}
  <script type="text/javascript" src="{% static "jquery-highlight/jquery.highlight.js" %}"></script>
  <!-- Flot Charts JavaScript -->
  <script src="{% static "flot/excanvas.min.js" %}"></script>
  <script src="{% static "flot/jquery.flot.js" %}"></script>
  <script src="{% static "flot/jquery.flot.pie.js" %}"></script>
  <script src="{% static "flot/jquery.flot.time.js" %}"></script>
  <script src="{% static "jquery.flot.tooltip/js/jquery.flot.tooltip.min.js" %}"></script>
  <script src="{% static "flot/jquery.flot.stack.js" %}"></script>
  <script src="{% static "flot/jquery.flot.resize.js" %}"></script>
  {% block metrics %}
      <script src="{% static "dojo/js/metrics.js" %}"></script>
  {% endblock metrics %}
  <script type="text/javascript">
    $(function() {
      if (document.referrer.indexOf('simple_search') > 0) {
        var terms = '';
        if ($.cookie('highlight')) {
          terms = $.cookie('highlight').split(' ');

          for (var i = 0; i < terms.length; i++) {
            $('body').highlight(terms[i]);
          }
        }

        $('input#simple_search').val(terms);
      }

      {% if languages and langSummary.files__count > 0 %}
        var data = [
          {% for lang in languages %}
            {% if lang.code %}
              {
                label: "&nbsp;{{lang}} - {{lang.code|intcomma}} LoC",
                color: "{{ lang.language.color }}",
                data: {{lang.code}}
              },
            {% endif %}
          {% endfor %}
        ];
        languages_pie(data);
      {% endif %}
    });

    $(function() {
      $('div#edit_notifications input[type=checkbox]').on('click', function() {
        $('#saving_notifications').append(' <small>({% trans "saving..." %})</small>')
        $('#edit_notifications_form').submit()
      });
    });

    $('[data-toggle="tooltip"]').tooltip()
  </script>
  {% endblock %}
